package io;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;


public class Output {

	
	    String menoVystupnehoSuboru;
	    String textNaZapis;
	    public Output(String menoVystupu, String textNaZapis)
	    {
	        menoVystupnehoSuboru = menoVystupu;
	        this.textNaZapis = textNaZapis;
	    }
	    
	    public void zapisSubor()
	    {
	        BufferedWriter out = null;
	        File vystupnySubor = null;
	        
	        try {
	            vystupnySubor = new File(menoVystupnehoSuboru);
	            if (!vystupnySubor.exists()) {
	                    vystupnySubor.createNewFile();
	                }
	            out = new BufferedWriter(new FileWriter(vystupnySubor));
	            out.write(textNaZapis);
	        } catch (IOException ex) {
	            Logger.getLogger(Output.class.getName()).log(Level.SEVERE, null, ex);
	        }
	        finally{
	            try {
	                out.close();
	            } catch (IOException ex) {
	                Logger.getLogger(Output.class.getName()).log(Level.SEVERE, null, ex);
	            }
	            
	        }
	        
	    }
	
}
